home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / gfx / opal / hspasov4.lha / Opal.pas next >
Pascal/Delphi Source File  |  1993-01-19  |  13KB  |  456 lines

  1. {--------------------------------------------------------------------------
  2.  
  3.                          OPALVISION LIBRARY UNIT
  4.  
  5.                    ( HighSpeed Pascal for the Amiga )
  6.  
  7.                    Programmed by Kelly J. Petlig 1992
  8.  
  9.                  Copyright (c) 1992 All rights reserved
  10.  
  11.   Version : Date (mm/dd/yy) : Comment
  12.   -----------------------------------
  13.     1.00 : 12/27/92 : First version
  14.     1.01 : 12/30/92 : Fixed bug (called procedures as functions)
  15.     1.02 : 12/31/92 : Added OpalRequestor procedure
  16.     1.03 : 01/11/93 : CloseScreen24 now is a procedure, not a function
  17.     1.04 : 01/13/93 : Bug in _fd file caused problem with LowMemUpdate24
  18.  
  19. --------------------------------------------------------------------------}
  20.  
  21. Unit Opal;
  22.  
  23. INTERFACE
  24.  
  25. Uses Exec, Intuition;
  26.  
  27. Const
  28.  
  29.   MAXCOPROINS   = 290;     { Number of CoPro instructions }
  30.  
  31.           { Screen flags }
  32.  
  33.   HIRES24       = $0001;   { High resolution screen. }
  34.   ILACE24       = $0002;   { Interlaced screen. }
  35.   OVERSCAN24    = $0004;   { Overscan screen. }
  36.   NTSC24        = $0008;   { NTSC Screen - Not user definable }
  37.   CLOSEABLE24   = $0010;   { Screen is closeable. }
  38.   PLANES8       = $0020;   { Screen has 8 bitplanes. }
  39.   PLANES15      = $0040;   { Screen has 15 bitplanes. }
  40.   CONTROLONLY24 = $2000;   { Used for updating control bits only }
  41.   PALMAP24      = $4000;   { Screen is in palette mapped mode }
  42.   INCHIP24      = $8000;   { In chip ram - Not user definable }
  43.  
  44.   FLAGSMASK24 = $6077;
  45.  
  46.           { LoadImage24 Flags }
  47.  
  48.   CONVERT24       = 1;  { Force conversion of palette mapped to 24 bit }
  49.   KEEPRES24       = 2;  { Keep the current screen resolution }
  50.   LOADMASK24      = 4;  { Load mask plane if it exists }
  51.   VIRTUALSCREEN24 = 8;  { Load complete image into fast ram }
  52.  
  53.           { SaveIFF24 Flags }
  54.  
  55.   OVFASTFORMAT = 1;     { Save as opalvision fast format }
  56.   NOTHUMBNAIL  = 4;     { Inhibit thumbnail chunk }
  57.   SAVEMASK24   = 8;     { Save MaskPlane with image }
  58.  
  59.           { Config Flags }
  60.  
  61.   OVCF_OPALVISION = 1;      { Display board is an OpalVision }
  62.   OVCF_COLORBURST = 2;      { Display board is a ColorBurst }
  63.  
  64.           { Opal Requestor Flags }
  65.  
  66.   NO_INFO   = 1;        { Exclude files ending in .info }
  67.   LASTPATH  = 2;        { Use Last selected path as current }
  68.  
  69.   OR_ERR_OUTOFMEM = 1;
  70.   OR_ERR_INUSE    = 2;
  71.  
  72.   OPALREQ_HEIGHT  = 345;    { The height of the Requester }
  73.  
  74.           { Coprocessor bits. }
  75.  
  76.   VIDMODE0     = $01;    { Video control bit 1 (S0) }
  77.   VIDMODE1     = $02;    { Video control bit 1 (S1) }
  78.   DISPLAYBANK2 = $04;    { Select display bank 2 }
  79.   HIRESDISP    = $08;    { Enable hi-res display }
  80.   DUALDISPLAY  = $10;    { Select dual display mode (active low) }
  81.   OVPRI        = $20;    { Set OpalVision priority }
  82.   PRISTENCIL   = $40;    { Enable priority stencil }
  83.   ADDLOAD      = $80;    { Address load bit. Active low }
  84.  
  85.   ADDLOAD_B      = 7;
  86.   PRISTENCIL_B   = 6;
  87.   OVPRI_B        = 5;
  88.   DUALDISPLAY_B  = 4;
  89.   HIRESDISP_B    = 3;
  90.   DISPLAYBANK2_B = 2;
  91.   VIDMODE1_B     = 1;
  92.   VIDMODE0_B     = 0;
  93.  
  94.           { Control line bits }
  95.  
  96.   VALID0        = $00001;
  97.   VALID1        = $00002;
  98.   VALID2        = $00004;
  99.   VALID3        = $00008;
  100.   WREN          = $00010;
  101.   COL_COPRO     = $00020;
  102.   AUTO          = $00040;
  103.   DUALPLAYFIELD = $00080;
  104.   FIELD         = $00100;
  105.   AUTOFIELD     = $00200;
  106.   DISPLAYLATCH  = $00400;
  107.   FRAMEGRAB     = $00800;
  108.   RWR1          = $01000;
  109.   RWR2          = $02000;
  110.   GWR1          = $04000;
  111.   GWR2          = $08000;
  112.   BWR1          = $10000;
  113.   BWR2          = $20000;
  114.   VLSIPROG      = $40000;
  115.   FREEZEFRAME   = $80000;
  116.  
  117.   VALID0_B        =  0;
  118.   VALID1_B        =  1;
  119.   VALID2_B        =  2;
  120.   VALID3_B        =  3;
  121.   WREN_B          =  4;
  122.   COL_COPRO_B     =  5;
  123.   AUTO_B          =  6;
  124.   DUALPLAYFIELD_B =  7;
  125.   FIELD_B         =  8;
  126.   AUTOFIELD_B     =  9;
  127.   DISPLAYLATCH_B  = 10;
  128.   FRAMEGRAB_B     = 11;
  129.   RWR1_B          = 12;
  130.   RWR2_B          = 13;
  131.   GWR1_B          = 14;
  132.   GWR2_B          = 15;
  133.   BWR1_B          = 16;
  134.   BWR2_B          = 17;
  135.   VLSIPROG_B      = 18;
  136.   FREEZEFRAME_B   = 19;
  137.  
  138.   NUMCONTROLBITS  = 20;
  139.   VALIDCODE       =  5;
  140.  
  141.           { Error return codes }
  142.  
  143.   OL_ERR_OUTOFMEM      =  1;
  144.   OL_ERR_OPENFILE      =  2;
  145.   OL_ERR_NOTIFF        =  3;
  146.   OL_ERR_FORMATUNKNOWN =  3;
  147.   OL_ERR_NOTILBM       =  4;
  148.   OL_ERR_FILEREAD      =  5;
  149.   OL_ERR_FILEWRITE     =  6;
  150.   OL_ERR_BADIFF        =  7;
  151.   OL_ERR_CANTCLOSE     =  8;
  152.   OL_ERR_OPENSCREEN    =  9;
  153.   OL_ERR_NOTHUMBNAIL   = 10;
  154.   OL_ERR_BADJPEG       = 11;
  155.   OL_ERR_UNSUPPORTED   = 12;
  156.   OL_ERR_CTRLC         = 13;
  157.   OL_ERR_MAXERR        = 40;
  158.  
  159. Type
  160.   tOpalScreen = Record
  161.     Width : Integer;
  162.     Height : Integer;
  163.     Depth : Integer;            { Is this actually Depth / 2 ? }
  164.     ClipX1,ClipY1 : Integer;
  165.     ClipX2,ClipY2 : Integer;
  166.     BytesPerLine : Integer;
  167.     Flags : Word;
  168.     RelX : Integer;
  169.     RelY : Integer;
  170.     UserPort : pMsgPort;
  171.     MaxFrames : Integer;
  172.     VStart : Integer;
  173.     CoProOffset : Integer;
  174.     LastWait : Integer;
  175.     LastCoProIns : Word;
  176.     BitPlanes : Array [0..23] of pShortInt; { 24 }
  177.     MaskPlane : pShortInt;
  178.     AddressReg : LongInt;
  179.     UpdateDelay : Byte;
  180.     PalLoadAddress : Byte;
  181.     PixelReadMask : Byte;
  182.     CommandReg : Byte;
  183.     Palette : Array [0..767] of Byte; { 3 * 256 }
  184.     Pen_R : Byte;
  185.     Pen_G : Byte;
  186.     Pen_B : Byte;
  187.     Red : Byte;
  188.     Green : Byte;
  189.     Blue : Byte;
  190.     CoProData : Array [0..289] of Byte; { MAXCOPROINS }
  191.     Modulo : Integer;
  192.     Reserved : Array [0..37] of Byte; { 38 }
  193.  
  194.   {$Ifdef OPAL_PRIVATE }
  195.     CopList_Cycle : Array [0..11] of LongInt; { 12 }
  196.     Update_Cycles : Byte;
  197.     Pad : Byte;
  198.   {$endif }
  199.  
  200.     end;
  201.  
  202.   pOpalScreen = ^tOpalScreen;
  203.  
  204.   tOpalReqBase = Record
  205.           OR_Lib : tLibrary;
  206.           OR_SegList : LongInt;
  207.           end;
  208.  
  209.   tOpalReq = Record
  210.           TopEdge : Word;         { Top Line of requester }
  211.           Hail : pShortInt;       { Hailing text }
  212.           File_ : pShortInt;      { Filename buffer (>=31 chars) }
  213.           Dir : pShortInt;        { Directory name. }
  214.           Extension : pShortInt;  { File extension to include }
  215.           Window : pWindow;       { Window to display requester. }
  216.           OScrn : pOpalScreen;    { OpalScreen to display req. }
  217.           Pointer : pWord;        { Sprite mouse pointer }
  218.           OKHit : Integer;        { TRUE if OK gadget hit }
  219.           NeedRefresh : Integer;  { OpalScreen needs a refresh }
  220.           Flags : LongInt;        { See Below }
  221.           BackPen : Integer;      { Pen # to use for BG rendering }
  222.           PrimaryPen : Integer;   { Pen # for primary rendering }
  223.           SecondaryPen : Integer; { Pen # for secondary rendering }
  224.           end;
  225.  
  226. pOpalReq = ^tOpalReq;
  227.  
  228. Var
  229.   OpalBase: pLibrary;
  230.   OpalReqBase : pOpalReq;
  231.  
  232. Function OpenScreen24 (Modes: LongInt): pOpalScreen;
  233. Procedure CloseScreen24;
  234. Function WritePixel24
  235.                  (Screen: pOpalScreen;
  236.                   x,
  237.                   y: LongInt): LongInt;
  238.  
  239. Function ReadPixel24
  240.                  (Screen: pOpalScreen;
  241.                   x,
  242.                   y: LongInt): LongInt;
  243.  
  244. Procedure ClearScreen24 (Screen: pOpalScreen);
  245. Procedure ILBMtoOV
  246.                  (Screen : pOpalScreen;
  247.                   ILBMData: Pointer;
  248.                   SourceWidth,
  249.                   Lines,
  250.                   TopLine,
  251.                   Planes: LongInt);
  252.  
  253. Procedure UpdateDelay24 (Frames: LongInt);
  254. Procedure Refresh24;
  255. Function SetDisplayBottom24 (BottomLine: LongInt): LongInt;
  256. Procedure ClearDisplayBottom24;
  257. Procedure SetSprite24
  258.                  (SpriteData: Pointer;
  259.                   SpriteNum: LongInt);
  260.  
  261. Procedure AmigaPriority;
  262. Procedure OVPriority;
  263. Procedure DualDisplay24;
  264. Procedure SingleDisplay24;
  265. Procedure AppendCopper24 (CopperArray: Pointer);
  266. Procedure RectFill24
  267.                  (Screen: pOpalScreen;
  268.                   x1,
  269.                   y1,
  270.                   x2,
  271.                   y2: LongInt);
  272.  
  273. Procedure UpdateCoPro24;
  274. Procedure SetControlBit24
  275.                  (List,
  276.                   Bit,
  277.                   State: LongInt);
  278.  
  279. Procedure PaletteMap24 (State: LongInt);
  280. Procedure UpdatePalette24;
  281. Procedure Scroll24
  282.                  (Deltax,
  283.                   Deltay: LongInt);
  284.  
  285. Function LoadImage24
  286.                  (Screen: pOpalScreen;
  287.                   FileName: pCString;
  288.                   Flags: LongInt): LongInt;
  289.  
  290. Procedure SetScreen24 (Screen: pOpalScreen);
  291. Function SaveIFF24
  292.                  (Screen: pOpalScreen;
  293.                   FileName: pCString;
  294.                   ChunkFunc: Pointer;
  295.                   Flags: LongInt): LongInt;
  296.  
  297. Function CreateScreen24
  298.                  (ScreenModes,
  299.                   Width,
  300.                   Height: LongInt): pOpalScreen;
  301.  
  302. Procedure FreeScreen24 (Screen: pOpalScreen);
  303. Procedure UpdateRegs24;
  304. Procedure SetLoadAddress24;
  305. Procedure RGBtoOV
  306.                  (Screen: pOpalScreen;
  307.                   RGBData: Pointer;
  308.                   x,
  309.                   y,
  310.                   w,
  311.                   h: LongInt);
  312.  
  313. Function ActiveScreen24: pOpalScreen;
  314. Procedure FadeIn24 (HundredthsSecs: LongInt);  { Must be > 1 }
  315. Procedure FadeOut24 (HundredthsSecs: LongInt);   { Must be > 1 }
  316. Procedure ClearQuick24;
  317. Function WriteThumbnail24
  318.                  (Screen: pOpalScreen;
  319.                   File_: Pointer): LongInt;
  320.  
  321. Procedure SetRGB24
  322.                  (Entry,
  323.                   R,
  324.                   G,
  325.                   B: LongInt);
  326.  
  327. Procedure DrawLine24
  328.                  (Screen: pOpalScreen;
  329.                   x1,
  330.                   y1,
  331.                   x2,
  332.                   y2: LongInt);
  333.  
  334. Procedure StopUpdate24;
  335. Function WritePFPixel24
  336.                  (Screen: pOpalScreen;
  337.                   x,
  338.                   y: LongInt): LongInt;
  339.  
  340. Function WritePRPixel24
  341.                  (Screen: pOpalScreen;
  342.                   x,
  343.                   y: LongInt): LongInt;
  344.  
  345. Function OVtoRGB
  346.                  (Screen: pOpalScreen;
  347.                   RGBData: Pointer;
  348.                   x,
  349.                   y,
  350.                   w,
  351.                   h: LongInt): LongInt;
  352.  
  353. Procedure OVtoILBM
  354.                  (Screen: pOpalScreen;
  355.                   ILBMData: Pointer;
  356.                   DestWidth,
  357.                   Lines,
  358.                   TopLine: LongInt);
  359.  
  360. Procedure UpdateAll24;
  361. Procedure UpdatePFStencil24;
  362. Procedure EnablePRStencil24;
  363. Procedure DisablePRStencil24;
  364. Procedure ClearPRStencil24 (Screen: pOpalScreen);
  365. Procedure SetPRStencil24 (Screen: pOpalScreen);
  366. Procedure DisplayFrame24 (Frame: LongInt);
  367. Procedure WriteFrame24 (Frame: LongInt);
  368. Procedure BitPlanetoOV
  369.                  (Screen: pOpalScreen;
  370.                   SrcPlanes: Pointer;
  371.                   BytesPerLine,
  372.                   Lines,
  373.                   TopLine,
  374.                   Depth: LongInt);
  375.  
  376. Procedure SetCoPro24
  377.                  (Line,
  378.                   Instruction: LongInt);
  379.  
  380. Procedure RegWait24;
  381. Procedure DualPlayField24;
  382. Procedure SinglePlayField24;
  383. Procedure ClearPFStencil24 (Screen: pOpalScreen);
  384. Procedure SetPFStencil24 (Screen: pOpalScreen);
  385. Function ReadPRPixel24
  386.                  (Screen: pOpalScreen;
  387.                   x,
  388.                   y: LongInt): LongInt;
  389.  
  390. Function ReadPFPixel24
  391.                  (Screen: pOpalScreen;
  392.                   x,
  393.                   y: LongInt): LongInt;
  394.  
  395. Procedure OVtoBitPlane
  396.                  (Screen: pOpalScreen;
  397.                   DestPlanes: Pointer;
  398.                   DestWidth,
  399.                   Lines,
  400.                   TopLine: LongInt);
  401.  
  402. Procedure FreezeFrame24 (Freeze: LongInt);
  403. Function LowMemUpdate24
  404.                  (Screen: pOpalScreen;
  405.                   Frame: LongInt): pOpalScreen;
  406. Function DisplayThumbnail24
  407.                  (Screen: pOpalScreen;
  408.                   FileName: pCString;
  409.                   x,
  410.                   y: LongInt): LongInt;
  411.  
  412. Function Config24: LongInt;
  413. Procedure AutoSync24 (Sync: LongInt);
  414. Procedure DrawEllipse24
  415.                  (Screen: pOpalScreen;
  416.                   Cx,
  417.                   Cy,
  418.                   a,
  419.                   b: LongInt);
  420.  
  421. Procedure LatchDisplay24 (Latch: LongInt);
  422. Procedure SetHires24
  423.                  (TopLine,
  424.                   Lines: LongInt);
  425.  
  426. Procedure SetLores24
  427.                  (TopLine,
  428.                   Lines: LongInt);
  429.  
  430. Function DownLoadFrame24
  431.                  (Screen: pOpalScreen;
  432.                   x,
  433.                   y,
  434.                   w,
  435.                   h: LongInt): LongInt;
  436.  
  437. Function SaveJPEG24
  438.                  (Screen: pOpalScreen;
  439.                   FileName: pCString;
  440.                   Flags,
  441.                   Quality: LongInt): LongInt;
  442.  
  443. Function LowMem2Update24
  444.                  (Screen: pOpalScreen;
  445.                   Frame: LongInt): pOpalScreen;
  446.  
  447. Function LowMemRGB24
  448.                  (Screen: pOpalScreen;
  449.                   Frame,
  450.                   Width,
  451.                   Height,
  452.                   Modulo: LongInt;
  453.                   RGBPlanes: Pointer): pOpalScreen;
  454.  
  455. Procedure OpalRequestor (OpalReq : pOpalReq);
  456.